package com.haiyou.dc.thread;

public class Web12306 implements Runnable {

    private int ticketNum = 20;

    @Override
    public void run() {
        while (true) {
            if (ticketNum <= 0) {
                break;
            }
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "---->" + ticketNum--);
        }
    }

    public static void main(String[] args) {
        Web12306 web12306 = new Web12306();
        new Thread(web12306, "001").start();
        new Thread(web12306, "002").start();
        new Thread(web12306, "003").start();
        new Thread(web12306, "004").start();
        new Thread(web12306, "005").start();
    }
}
